<div id="Conflicts-example"></div>
<div class="header">
<p>
Next: [[cvs: Informing others about commits#Informing others about commits|Informing others]], Previous: [[cvs: Bringing a file up to date#Bringing a file up to date|Updating a file]], Up: [[cvs: Multiple developers#Multiple developers|Multiple developers]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>

----

<div id="Conflicts-example-1"></div>
=== Conflicts example ===
<div id="index-Merge_002c-an-example"></div>
<div id="index-Example-of-merge"></div>
<div id="index-driver_002ec-_0028merge-example_0029"></div>

Suppose revision 1.4 of &lsquo;<tt>driver.c</tt>&rsquo; contains this:

<div class="example" style="margin-left: 3.2em">
 #include &lt;stdio.h&gt;
 
 void main()
 <nowiki>{</nowiki>
     parse();
     if (nerr == 0)
         gencode();
     else
         fprintf(stderr, &quot;No code generated.\n&quot;);
     exit(nerr == 0 ? 0 : 1);
 <nowiki>}</nowiki>
</div>

Revision 1.6 of &lsquo;<tt>driver.c</tt>&rsquo; contains this:

<div class="example" style="margin-left: 3.2em">
 #include &lt;stdio.h&gt;
 
 int main(int argc,
          char **argv)
 <nowiki>{</nowiki>
     parse();
     if (argc != 1)
     <nowiki>{</nowiki>
         fprintf(stderr, &quot;tc: No args expected.\n&quot;);
         exit(1);
     <nowiki>}</nowiki>
     if (nerr == 0)
         gencode();
     else
         fprintf(stderr, &quot;No code generated.\n&quot;);
     exit(!!nerr);
 <nowiki>}</nowiki>
</div>

Your working copy of &lsquo;<tt>driver.c</tt>&rsquo;, based on revision
1.4, contains this before you run &lsquo;<code>cvs update</code>&rsquo;:

<div class="example" style="margin-left: 3.2em">
 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 
 void main()
 <nowiki>{</nowiki>
     init_scanner();
     parse();
     if (nerr == 0)
         gencode();
     else
         fprintf(stderr, &quot;No code generated.\n&quot;);
     exit(nerr == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 <nowiki>}</nowiki>
</div>

You run &lsquo;<code>cvs update</code>&rsquo;:

<div class="example" style="margin-left: 3.2em">
 $ cvs update driver.c
 RCS file: /usr/local/cvsroot/yoyodyne/tc/driver.c,v
 retrieving revision 1.4
 retrieving revision 1.6
 Merging differences between 1.4 and 1.6 into driver.c
 rcsmerge warning: overlaps during merge
 cvs update: conflicts found in driver.c
 C driver.c
</div>

<div id="index-Conflicts-_0028merge-example_0029"></div>
<small>CVS</small> tells you that there were some conflicts.
Your original working file is saved unmodified in
&lsquo;<tt>.#driver.c.1.4</tt>&rsquo;.  The new version of
&lsquo;<tt>driver.c</tt>&rsquo; contains this:

<div class="example" style="margin-left: 3.2em">
 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 
 int main(int argc,
          char **argv)
 <nowiki>{</nowiki>
     init_scanner();
     parse();
     if (argc != 1)
     <nowiki>{</nowiki>
         fprintf(stderr, &quot;tc: No args expected.\n&quot;);
         exit(1);
     <nowiki>}</nowiki>
     if (nerr == 0)
         gencode();
     else
         fprintf(stderr, &quot;No code generated.\n&quot;);
 &lt;&lt;&lt;&lt;&lt;&lt;&lt; driver.c
     exit(nerr == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 =======
     exit(!!nerr);
 &gt;&gt;&gt;&gt;&gt;&gt;&gt; 1.6
 <nowiki>}</nowiki>
</div>

<div id="index-Markers_002c-conflict"></div>
<div id="index-Conflict-markers"></div>
<div id="index-_003c_003c_003c_003c_003c_003c_003c"></div>
<div id="index-_003e_003e_003e_003e_003e_003e_003e"></div>
<div id="index-_003d_003d_003d_003d_003d_003d_003d"></div>

Note how all non-overlapping modifications are incorporated in your working
copy, and that the overlapping section is clearly marked with
&lsquo;<code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code>&rsquo;, &lsquo;<code>=======</code>&rsquo; and &lsquo;<code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>&rsquo;.

<div id="index-Resolving-a-conflict"></div>
<div id="index-Conflict-resolution"></div>
You resolve the conflict by editing the file, removing the markers and
the erroneous line.  Suppose you end up with this file:
<div class="example" style="margin-left: 3.2em">
 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 
 int main(int argc,
          char **argv)
 <nowiki>{</nowiki>
     init_scanner();
     parse();
     if (argc != 1)
     <nowiki>{</nowiki>
         fprintf(stderr, &quot;tc: No args expected.\n&quot;);
         exit(1);
     <nowiki>}</nowiki>
     if (nerr == 0)
         gencode();
     else
         fprintf(stderr, &quot;No code generated.\n&quot;);
     exit(nerr == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 <nowiki>}</nowiki>
</div>

You can now go ahead and commit this as revision 1.7.

<div class="example" style="margin-left: 3.2em">
 $ cvs commit -m &quot;Initialize scanner. Use symbolic exit values.&quot; driver.c
 Checking in driver.c;
 /usr/local/cvsroot/yoyodyne/tc/driver.c,v  &lt;--  driver.c
 new revision: 1.7; previous revision: 1.6
 done
</div>

For your protection, <small>CVS</small> will refuse to check in a
file if a conflict occurred and you have not resolved
the conflict.  Currently to resolve a conflict, you
must change the timestamp on the file.  In previous
versions of <small>CVS</small>, you also needed to
insure that the file contains no conflict markers.
Because
your file may legitimately contain conflict markers (that
is, occurrences of &lsquo;<code>&gt;&gt;&gt;&gt;&gt;&gt;&gt; </code>&rsquo; at the start of a
line that don&rsquo;t mark a conflict), the current
version of <small>CVS</small> will print a warning and proceed to
check in the file.

<div id="index-emerge"></div>
If you use release 1.04 or later of pcl-cvs (a <small>GNU</small>
Emacs front-end for <small>CVS</small>) you can use an Emacs
package called emerge to help you resolve conflicts.
See the documentation for pcl-cvs.


----

<div class="header">
<p>
Next: [[cvs: Informing others about commits#Informing others about commits|Informing others]], Previous: [[cvs: Bringing a file up to date#Bringing a file up to date|Updating a file]], Up: [[cvs: Multiple developers#Multiple developers|Multiple developers]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>
This document was generated on <i>a sunny day</i> using [http://www.nongnu.org/texi2html/ <i>texi2html</i>].
